<%
    Users user = Trader.getUser(request.getParameter("uid"));
	wstrader.task.home.DailyBasisDiscount task = user.home.daily_basis_disc;

	task.getRequest().setRequest(request);
	task.getResponse().setResponse(response,out);
	long focused_id=0;
	if (!user.Authenticated()) {
		response.sendRedirect("logon.jsp");
		return;
	}
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);	
	focused_id = task.discount_daily_basis.doTask();
	//Record rc   = task.getRecord("grade_discount_allowance_details",focused_id);	
	Record rc = new Record(task.discount_daily_basis.getDetails(focused_id));
	Trader.window_width = "900";	
	
	int dLoop=0;
	ResultSet Rs;
	ResultSet rs;
%>

<%@include file="../header.jsp"%><style type="text/css">
<!--
.style1 {
	font-family: Arial;
	font-size: 12px;
}
.style3 {font-weight: bold}
.style4 {font-family: Arial; font-size: 12px; font-weight: bold; }
.style5 {
	font-family: Arial;
	font-size: 10px;
}
-->
</style>

<script language="javascript">
function doListView()
{
	var form = document.formMain;
	form.action = "home.daily-basis-d.jsp";
	form.submit();
}
function doAddNew_Discount()
{
	var form = document.formMain;
	form.id.value = "<%=task.getLastID("grade_discount_allowance_details") + 1%>";
	form.black_discount.value = 0;
	form.black_allowance.value = 0;
	form.broken_discount.value = 0;
	form.broken_allowance.value = 0;
	form.blk_brk_discount.value = 0;
	form.blk_brk_allowance.value = 0;
	form.brown_discount.value = 0;
	form.brown_allowance.value = 0;
	form.excelsa_discount.value = 0;
	form.excelsa_allowance.value =0;
	form.moldy_discount.value = 0;
	form.moldy_allowance.value =0;
	form.moisture_discount.value =0;
	form.moisture_allowance.value =0;
	form.foreign_matter_discount.value =0;
	form.foreign_matter_allowance.value =0.
	form.sc18_discount.value =0;
	form.sc18_allowance.value =0;
	form.sc16_discount.value =0;
	form.sc16_allowance.value =0;
	form.sc14_discount.value =0;
	form.sc14_allowance.value =0;
	form.sc13_discount.value =0;
	form.sc13_allowance.value =0;
	form.sc12_discount.value =0;
	form.sc12_allowance.value =0;
	form.below_sc12_discount.value =0;
	form.below_sc12_allowance.value =0;
}
function doUpdate()
{
	doTask(1);
}


</script>
<form action="" method="post" name="formMain" id="formMain">
  <table width="100%"  border="0.5" cellspacing="0" cellpadding="0">
    <tr>
      <td width="35%"><img src="images/discount-dailybasis.jpg" width="400" height="30"></td>
      <td width="65%">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
        <input type="hidden" name="task_id"    id = "task_id"   value="0"></td>
    </tr>
    <tr>
      <td colspan="2" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td width="91%" height="255"><table width="100%"  border="1" cellspacing="0" cellpadding="0" bordercolor="EEEEEE">
            <tr align="center" valign="top">
              <td height="25" colspan="14" class="style4"><table width="80%"  border="0.5" cellspacing="0" cellpadding="0" bordercolor="EEEEEE">
                <tr>
                  <td width="22%" height="32" align="right" class="style1">Origin</td>
                  <td width="2%">&nbsp;</td>
                  <td width="76%">
				  <select name="origin_id" id="origin_id" style="width:380px">
				  	<%
						task.getResponse().setOption("origin_master","name");
						task.getResponse().setSelected("origin_id",rc.getIntValue("origin_id"));
					%>
                  </select>
				  <input name="id" type="hidden" id="id" value="<%=rc.getIntValue("id")%>"></td>
                </tr>
                <tr>
                  <td height="31" align="right" class="style1">Quality</td>
                  <td>&nbsp;</td>
                  <td>
				  <select name="quality_id" id="quality_id" style="width:380px">
				  	<%
						task.getResponse().setOption("quality_master","name");
						task.getResponse().setSelected("quality_id",rc.getIntValue("quality_id"));
					%>
                  </select></td>
                </tr>
                <tr>
                  <td height="31" align="right" class="style1">Grade</td>
                  <td>&nbsp;</td>
                  <td>
				  <select name="grade_master_id" id="grade_master_id" style="width:380px">
					<%@include file="include/DiscountGradeList.jsp"%>
                  </select></td>
                </tr>
                <tr>
                  <td align="right" class="style1">Description</td>
                  <td>&nbsp;</td>
                  <td><textarea name="description" id="description" style="width:380"></textarea></td>
                </tr>
              </table></td>
              </tr>
            <tr>
              <td height="25" colspan="2" align="center" class="style4">&nbsp;</td>
              <td>&nbsp;</td>
              <td width="6%">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="25" colspan="2" align="center" class="style4">&nbsp;</td>
              <td>&nbsp;</td>
              <td colspan="3" align="center" valign="middle" bgcolor="#DDDDDD" class="style4">Defects</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td colspan="3" align="center" valign="middle" bgcolor="#DDDDDD" class="style4">Screen</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="25" colspan="2" align="center" class="style4">&nbsp;</td>
              <td width="1%">&nbsp;</td>
              <td align="center" valign="middle" class="style4">Discount</td>
              <td width="6%" align="center" valign="middle" class="style4">Premium</td>
              <td width="7%" align="center" valign="middle" class="style4">Allowance</td>
              <td width="1%">&nbsp;</td>
              <td width="18%">&nbsp;</td>
              <td width="1%">&nbsp;</td>
              <td width="6%" align="center" valign="middle" class="style4">Discount</td>
              <td width="6%" align="center" valign="middle" class="style4">Premium</td>
              <td width="6%" align="center" valign="middle" class="style4">Allowance</td>
              <td width="1%">&nbsp;</td>
              <td width="19%">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" colspan="2" align="right" class="style1">Black</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="black_discount" type="text" id="black_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("black_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="black_premium" type="text" id="black_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("black_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="black_allowance" type="text" id="black_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("black_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Screen 18 </td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="sc18_discount" type="text" id="sc18_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc18_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc18_premium" type="text" id="sc18_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc18_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc18_allowance" type="text" id="sc18_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc18_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="28" colspan="2" align="right" class="style1">Broken</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="broken_discount" type="text" id="broken_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("broken_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="broken_premium" type="text" id="broken_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("broken_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="broken_allowance" type="text" id="broken_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("broken_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Screen 16 </td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="sc16_discount" type="text" id="sc16_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc16_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc16_premium" type="text" id="sc16_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc16_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc16_allowance" type="text" id="sc16_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc16_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="28" colspan="2" align="right" class="style1">Black &amp; Broken </td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="blk_brk_discount" type="text" id="blk_brk_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("blk_brk_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="blk_brk_premium" type="text" id="blk_brk_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("blk_brk_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="blk_brk_allowance" type="text" id="blk_brk_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("blk_brk_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Screen14</td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="sc14_discount" type="text" id="sc14_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc14_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc14_premium" type="text" id="sc14_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc14_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc14_allowance" type="text" id="sc14_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc14_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="27" colspan="2" align="right" class="style1">Brown</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="brown_discount" type="text" id="brown_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("brown_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="brown_premium" type="text" id="brown_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("brown_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="brown_allowance" type="text" id="brown_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("brown_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Screen13</td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="sc13_discount" type="text" id="sc13_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc13_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc13_premium" type="text" id="sc13_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc13_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc13_allowance" type="text" id="sc13_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc13_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="28" colspan="2" align="right" class="style1">Excelsa</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="excelsa_discount" type="text" id="excelsa_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("excelsa_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="excelsa_premium" type="text" id="excelsa_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("excelsa_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="excelsa_allowance" type="text" id="excelsa_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("excelsa_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Screen 12 </td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="sc12_discount" type="text" id="sc12_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc12_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc12_premium" type="text" id="sc12_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc12_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="sc12_allowance" type="text" id="sc12_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("sc12_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="30" colspan="2" align="right" class="style1">Moldy</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="moldy_discount" type="text" id="moldy_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moldy_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="moldy_premium" type="text" id="moldy_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moldy_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="moldy_allowance" type="text" id="moldy_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moldy_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">Below Screen 12 </td>
              <td align="center" valign="middle">:</td>
              <td align="center" valign="middle"><input name="below_sc12_discount" type="text" id="below_sc12_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("below_sc12_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="below_sc12_premium" type="text" id="below_sc12_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("below_sc12_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="below_sc12_allowance" type="text" id="below_sc12_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("below_sc12_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="28" colspan="2" align="right" class="style1">Foreign Matter </td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="foreign_matter_discount" type="text" id="foreign_matter_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("foreign_matter_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="foreign_matter_premium" type="text" id="foreign_matter_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("foreign_matter_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="foreign_matter_allowance" type="text" id="foreign_matter_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("foreign_matter_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="29" colspan="2" align="right" class="style1">Mositure</td>
              <td align="center" class="style1">:</td>
              <td align="center" valign="middle"><input name="moisture_discount" type="text" id="moisture_discount" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moisture_discount"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="moisture_premium" type="text" id="mositure_premium" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moisture_premium"),0,"0")%>"></td>
              <td align="center" valign="middle"><input name="moisture_allowance" type="text" id="moisture_allowance" style="width:50px" value="<%=task.FormatZero(rc.getFloatValue("moisture_allowance"),0,"0")%>"></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td width="11%" height="29" align="center" class="style1">&nbsp;</td>
              <td width="11%" align="center" class="style1">&nbsp;</td>
              <td align="center" class="style1">&nbsp;</td>
              <td align="center" valign="middle"><span class="style1"><img src="images/new.gif" width="15" height="15" onClick="doAddNew_Discount();"></span></td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle"><span class="style1"><img src="images/update.gif" width="15" height="15" onClick="doUpdate();"></span></td>
              <td>&nbsp;</td>
              <td align="right" valign="middle" class="style1">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td align="center" valign="middle">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="right">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="right"><img src="images/listview.jpg" width="55" height="18" onClick="doListView();"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>

<%@include file="../footer.jsp"%>
